package com.bookmanger.server.mapper;

import com.bookmanger.pojo.Entity.ReaderEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ReadersMapper {
    @Select("SELECT * FROM reader WHERE id = #{id} AND is_delete = 0")
    ReaderEntity findById(Integer id);
    
    @Select("SELECT email FROM reader WHERE id = #{id}")
    String findEmailById(Integer id);

    @Update("UPDATE reader SET borrowed_number = borrowed_number + #{count} WHERE id = #{id}")
    int updateBorrowedNumber(@Param("id") Integer id, @Param("count") Integer count);
}